/*
* Copyright (c)  2017, ueboot.com
* All rights reserved.
* 2017-11-22 13:59:59
*/
package com.ueboot.weishop.repository.activity;

import com.ueboot.weishop.entity.activity.CrowResultEntity;
import com.ueboot.core.repository.BaseRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 *  Created by ziv.hung  on 2017-11-22 13:59:59.
 * @author ziv.hung
 * @since 2.0 by autocode
 */
@Repository
public interface CrowResultRepository extends BaseRepository<CrowResultEntity, Long> {

    /**
     * @param activityCode
     * @param periodNum
     * @return
     */
    List<CrowResultEntity> findByActivityCodeAndPeriodNum(String activityCode, String periodNum);

    List<CrowResultEntity> findTop20ByLotteryOrderByOpenDateDesc(String lottery);

    @Modifying
    @Query("UPDATE #{#entityName} oe set oe.issueDms = :issueDmsSet where oe.issueDms = :issueDmsWhere")
    Integer updateIssueDmsByIssueDms(@Param("issueDmsSet") Integer issueDmsSet, @Param("issueDmsWhere")  Integer issueDmsWhere);

    List<CrowResultEntity> findByIssueDms(Integer issueDms);
}
